package mapReduce.demo07_join.demo01_productOrderReduceJoin;

import mapReduce.writable.ProductOrderWritable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

public class ProductOrderGroupingComparator extends WritableComparator {

    public ProductOrderGroupingComparator() {
        super(ProductOrderWritable.class,true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {

        ProductOrderWritable aBean = (ProductOrderWritable) a;
        ProductOrderWritable bBean = (ProductOrderWritable) b;

        String aProductId = aBean.getProductId();
        String bProductId = bBean.getProductId();

        return aProductId.compareTo(bProductId);

    }
}
